package com.album.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.album.common.Constants;
 

/**
 * @author Devin.Hu
 * @date 2011-7-6
 * @version V1.0
 * @description VIPSHOP字符处理类
 */
public class StringUtils {
	/**
	 * 判断是否为空
	 * 
	 * @param obj
	 * @return
	 */
	public static boolean isNull(String obj) {
		if (null == obj || "".equals(obj)) {
			return true;
		}
		return false;
	}

	/**
	 * 判断是否符合邮箱格式
	 * 
	 * @param strEmail
	 * @return
	 */
	public static boolean isEmail(String strEmail) {
		String strPattern = "^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$";
		Pattern p = Pattern.compile(strPattern);
		Matcher m = p.matcher(strEmail);
		return !m.matches();
	}

	/**
	 * 得到格式化时间
	 * 
	 * @param timeInSeconds
	 * @return
	 */
	public static String getFormatTimeMsg(int timeInSeconds) {
		int hours, minutes, seconds;
		hours = timeInSeconds / 3600;
		timeInSeconds = timeInSeconds - (hours * 3600);
		minutes = timeInSeconds / 60;
		timeInSeconds = timeInSeconds - (minutes * 60);
		seconds = timeInSeconds;
		return (minutes+"分"+seconds+"秒");
	}
}
